package com.boot.project.controller;


import com.boot.project.domain.CommentDo;
import com.boot.project.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 评论的接口
 */
@RequestMapping("/comment")
@RestController
public class CommentController {
    @Autowired
    private CommentService commentService;

    // 新增评论接口
    @PostMapping()
    public Map<String, Object> save(@RequestBody CommentDo commentDo) {
        return commentService.save(commentDo);
    }

    // 返回某条资讯下面的所有评论
    @GetMapping()
    public List<CommentDo> list(@RequestParam Long infoId) {
        return commentService.list(infoId);
    }
}
